package com.binlan.testspringboot.controller;

import com.binlan.testspringboot.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private TestService testService;

    @RequestMapping("/testOne")
    public String testOne(String userName) {
        if (userName != null) {
            return testService.getTestInfo(userName);
        } else if ("x".equals(userName)) {
            return "x";
        } else if ("y".equals(userName)) {
            return "y";
        } else if ("z".equals(userName)) {
            return "z";
        } else if ("zz".equals(userName)) {
            return "z";
        }else {
            return "testOne";
        }
    }

    @RequestMapping("/testTwo")
    public String testTwo(String flag) {
        if ("1".equals(flag)) {
            return "1";
        } else if ("11".equals(flag)) {
            return "1";
        } else if ("2".equals(flag)) {
            return "2";
        } else {
            return "testTwo";
        }
    }

    @RequestMapping("/test3")
    public String test3(String str) {
        if ("xyz".equals(str)) {
            return str;
        } else if ("1".equals(str)) {
            return "2" + str;
        } else {
            return "test3";
        }
    }

}
